<template>
	<view class="content">
		<view class="goods-list">
			<view v-for="(item, index) in vehicleBoxGoodsVos" :key="index" class="goods-item" @tap="clickBoxInfo(item.boxIndex)">
				<!-- 正常,柜门关闭的情况 -->
				<view  v-if="item.boxStatus == '0'"  style="background-color: #4CAF50;">
					<text class="box-index">{{item.boxIndex}}号柜:</text>
					<text class="box-product-title">{{item.productName}}</text>
					<view class="button-box">
						<view class="">
							<text style="font-size: 36rpx;" class="price">价格:{{item.price}}</text>
							<text class="text-gray text-df" style="font-size: 24rpx;">剩余数量:{{item.count}}</text>
						</view>
					</view>
				</view>
				<!-- 处理关闭状态的柜子 -->
				<view v-else-if="item.boxStatus == '-1'"  style="background-color: #999999;">
					<text class="box-index">{{item.boxIndex}}号柜:</text>
					<text class="box-product-title">{{item.productName}}</text>
					<view class="button-box">
						<view class="">
							<text style="font-size: 36rpx;" class="price">价格:{{item.price}}</text>
							<text class="text-gray text-df" style="font-size: 24rpx;">剩余数量:{{item.count}}</text>
						</view>
					</view>
				</view>
				<!-- 处理红色,即柜门打开的情况 -->
				<view v-else  style="background-color: red;">
					<text class="box-index">{{item.boxIndex}}号柜:</text>
					<text class="box-product-title">{{item.productName}}</text>
					<view class="button-box">
						<view class="">
							<text style="font-size: 36rpx;" class="price">价格:{{item.price}}</text>
							<text class="text-gray text-df" style="font-size: 24rpx;">剩余数量:{{item.count}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	//引用mSearch组件，如不需要删除即可
	// import mSearch from '@/components/mehaotian-search-revision.vue';
	export default {
		data() {
			return {
				defaultKeyword: "输入车辆vehicleNo",
				keyword: "",
				oldKeywordList: [],
				hotKeywordList: [],
				keywordList: [],
				forbid: '',
				isShowKeywordList: false,
				oldUrl: 'https://app.mosunshine.com/prod-api/',
				newUrl: 'https://mall.mosunshine.com/',
				vehicleBoxGoodsVos: [],
				allCarGoods: [],
				nowCarNo: '',
				clickNo: -1,
			}
		},
		onLoad(options) {
			this.init(options);
		},
		components: {
			//引用mSearch组件，如不需要删除即可
		},
		methods: {
			init(options) {
				
			},
			clickBoxInfo(boxIndex) {
				const that = this
				const vehicleNo = that.nowCarNo
				uni.navigateTo({
					url: '../operator/carPayUpInfo?vehicleNo='+vehicleNo+'&boxIndex='+boxIndex
				})
			},
			//执行搜索
			doSearch() {
				const that = this
				that.nowCarNo = that.keyword
				uni.request({
					method:'GET',
				    url: that.newUrl +'vehicle/app/getVehicleBoxGoodsInfo',
					header: {
						'Authorization': 'Bearer '+ uni.getStorageSync('token'),
						'content-type': 'application/x-www-form-urlencoded',
					},
				    data: {
						vehicleNo:  that.nowCarNo
					},
				    success: (res) => {
						that.vehicleBoxGoodsVos = res.data.data.vehicleBoxGoodsVos
				    }
				});
			},
		}
	}
</script>
<style>
	view{display:block;}
	.goods-list {width:100%;}
	.goods-list .goods-item{width:100%;}
	.goods-list .box-index{width:100%;font-size: 28upx;color: #333;}
	.search-box {width:100%;background-color:rgb(242,242,242);padding:15upx 2.5%;display:flex;justify-content:space-between;}
	.search-box .mSearch-input-box{width: 100%;}
	.search-box .input-box {width:85%;flex-shrink:1;display:flex;justify-content:center;align-items:center;}
	.search-box .search-btn {width:15%;margin:0 0 0 2%;display:flex;justify-content:center;align-items:center;flex-shrink:0;font-size:28upx;color:#fff;background:linear-gradient(to right,#ff9801,#ff570a);border-radius:60upx;}
	.search-box .input-box>input {width:100%;height:60upx;font-size:32upx;border:0;border-radius:60upx;-webkit-appearance:none;-moz-appearance:none;appearance:none;padding:0 3%;margin:0;background-color:#ffffff;}
	.placeholder-class {color:#9e9e9e;}
	.search-keyword {width:100%;background-color:rgb(242,242,242);}
	.keyword-list-box {height:calc(100vh - 110upx);padding-top:10upx;border-radius:20upx 20upx 0 0;background-color:#fff;}
	.keyword-entry-tap {background-color:#eee;}
	.keyword-entry {width:94%;height:80upx;margin:0 3%;font-size:30upx;color:#333;display:flex;justify-content:space-between;align-items:center;border-bottom:solid 1upx #e7e7e7;}
	.keyword-entry image {width:60upx;height:60upx;}
	.keyword-entry .keyword-text,.keyword-entry .keyword-img {height:80upx;display:flex;align-items:center;}
	.keyword-entry .keyword-text {width:90%;}
	.keyword-entry .keyword-img {width:10%;justify-content:center;}
	.keyword-box {height:calc(100vh - 110upx);border-radius:20upx 20upx 0 0;background-color:#fff;}
	.keyword-box .keyword-block {padding:10upx 0;}
	.keyword-box .keyword-block .keyword-list-header {width:94%;padding:10upx 3%;font-size:27upx;color:#333;display:flex;justify-content:space-between;}
	.keyword-box .keyword-block .keyword-list-header image {width:40upx;height:40upx;}
	.keyword-box .keyword-block .keyword {width:94%;padding:3px 3%;display:flex;flex-flow:wrap;justify-content:flex-start;}
	.keyword-box .keyword-block .hide-hot-tis {display:flex;justify-content:center;font-size:28upx;color:#6b6b6b;}
	.keyword-box .keyword-block .keyword>view {display:flex;justify-content:center;align-items:center;border-radius:60upx;padding:0 20upx;margin:10upx 20upx 10upx 0;height:60upx;font-size:28upx;background-color:rgb(242,242,242);color:#6b6b6b;}
</style>
